using NodeCanvas.Variables;

namespace NodeCanvas.Actions
{
	[Category("✫ Blackboard")]
	[Description("Set a blackboard boolean variable")]
	public class SetBoolean : ActionTask
	{
		public enum SetMode
		{
			False = 0,
			True = 1,
			Toggle = 2
		}

		[RequiredField]
		public BBBool boolData = new BBBool
		{
			blackboardOnly = true
		};

		public SetMode setTo = SetMode.True;

		protected override string info
		{
			get
			{
				if (setTo == SetMode.Toggle)
				{
					return "Toggle " + boolData.ToString();
				}
				return "Set " + boolData.ToString() + " to " + setTo;
			}
		}

		protected override void OnExecute()
		{
			if (setTo == SetMode.Toggle)
			{
				boolData.value = !boolData.value;
			}
			else
			{
				bool value = setTo == SetMode.True;
				boolData.value = value;
			}
			EndAction();
		}
	}
}
